class Promise {
  constructor(fn) {
    this.callbacks = [];
    fn(this._resolve.bind(this));
  }
  then(onFulfilled) {
    this.callbacks.push(onFulfilled);
    return this;
  }
  _resolve(value) {
    this.callbacks.forEach(fn => fn(value));
  }
}

let p = new Promise(function(resolve) {
  setTimeout(() => {
    console.log('done');
    resolve('5秒');
  }, 5000);
}).then((tip) => {
  console.log(tip);
}).then(tip => {
  console.log('tip ', tip)
})